#Conditional Hooks

$Application: FS2_Open
$State: GS_STATE_GAME_PLAY
$On Frame:

[

-- get mission time
if missiontime == nil then
   missiontime = mn.getMissionTime()
   oldmissiontime = missiontime
end


-- if the time is valid
if missiontime ~= nil then
	-- if we are actually doing something
	missiontime = mn.getMissionTime()
	-- only continue if the time actually progresses
	if oldmissiontime ~= missiontime then
		plr = hv.Player
		-- only continue if we can get valid player handle
		if plr:isValid() then
			local player_dir = plr.Orientation:getFvec():getNormalized()
			local offset = plr.Position + plr.Orientation:unrotateVector(plr.Class.Model.Eyepoints[1].Position)
			local screenX, screenY = (offset + player_dir):getScreenCoords()
			-- get the player's current velocity vector
			local velocity = (plr.Physics.Velocity + offset)
			vel_screen_x, vel_screen_y = velocity:getScreenCoords()
			if screenX ~= false and vel_screen_x ~= false then
				gr.setColor(0,255,0,200)
				gr.drawGradientLine(vel_screen_x, vel_screen_y, screenX, screenY)
				-- make sure oldmissiontime is incremented
				oldmissiontime = missiontime
			end
		end
	end
end

]

#End